// JavaScript Document
function previewImage(file,DivId,ImgId,MAXWIDTH,MAXHEIGHT,close_btn_id,nextDiv)
{
  var div = document.getElementById(DivId);
  var nextdiv=document.getElementById(nextDiv);
  if (file.files && file.files[0])
  {
    div.innerHTML = "<img"+" id="+ImgId+">";
    var img = document.getElementById(ImgId);
    img.onload = function(){
      var rect = clacImgZoomParam( MAXWIDTH, MAXHEIGHT,img.offsetWidth, img.offsetHeight);
      img.width = rect.width;
      img.height = rect.height;
      img.style.marginLeft = rect.left+'px';
      img.style.marginTop = rect.top+'px';
    }
    var reader = new FileReader();
    reader.onload = function(evt){img.src = evt.target.result;}
    reader.readAsDataURL(file.files[0]);
	var po_close = document.getElementById(close_btn_id);
	po_close.style.display = 'block';
  }
  else
  {
    var sFilter='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';
    file.select();
    var src = document.selection.createRange().text;
    div.innerHTML = "<img"+" id="+ImgId+">";
    var img = document.getElementById(ImgId);
    img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;
    var rect = clacImgZoomParam( img.offsetWidth, img.offsetHeight);
    status =('rect:'+rect.top+','+rect.left+','+rect.width+','+rect.height);
    div.innerHTML = "<div id=divhead style='width:"+rect.width+"px;height:"+rect.height+"px;margin-top:"+rect.top+"px;margin-left:"+rect.left+"px;"+sFilter+src+"\"'></div>";
	/*把关闭的显示在这里  close_po_btn1*/
	var po_close = document.getElementById(close_btn_id);
	po_close.style.display = 'block';
  }
  nextdiv.style.display = 'block';
}
function clacImgZoomParam(width, height ){
    var param = {width:width, height:height};
    return param;
}

/*删除在本地上传的图片的SRC*/
function clearImgSrc (ImgId,close_btn_id)
{
	var obj_img = document.getElementById(ImgId);
	obj_img.src = '';
	var obj_div = document.getElementById(close_btn_id);
	obj_div.style.display = 'none';
}